package com.hyacinth.cloudnote.modules.note.repository;

import com.hyacinth.cloudnote.modules.note.model.NoteBook;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
import org.springframework.data.repository.Repository;

import java.util.Optional;
import java.util.UUID;

/**
 * NoteBook实体类对应的基础业务Repository
 */
@org.springframework.stereotype.Repository
public interface NoteBookRepository extends Repository<NoteBook, UUID>, QuerydslPredicateExecutor<NoteBook> {

    NoteBook save(NoteBook model);

    Optional<NoteBook> findById(UUID id);

    Page<NoteBook> findAll(Pageable pageable);

    boolean existsByName(String name);

    boolean existsByNameAndIdNot(String name, UUID id);

    void delete(NoteBook noteBook);
}
